<?php
spl_autoload_call('ss_dao_structure');

class site_dao_node extends ss_dao_node{
	
}


class site_dao_structure extends ss_dao_structure{
	public function getMenu($selected='/'){
		ss_error::log($selected,'Menu for');
		if(is_null($selected)) $selected='/';
		$current=$this->getNodeFromSlug($selected);
		ss_error::log($current->level(),'Level');
		ss_error::log($current->hasChildren(),'children');
		if($current->level <= 1 && !$current->hasChildren()){
			ss_error::log('One line');
		} else {
			ss_error::log('Two lines');
		}
	}
}

class site_dao_structure_mapper extends ss_dao_structure_mapper{
	
	public function setInjector(Phemto $injector){
		$this->injector=$injector;
		$this->structure=$this->injector->fill('primary')->with('idstructure')->create('site_dao_structure');
	}
	
	public function getFullActiveStructure(){
		//$result=$this->injector->fill('primary')->with('idstructure')->create('site_dao_structure');
		$result=$this->structure;
		if($result->active()) return $result;
		return $this->master();
		$q=$this->getQueryBuilder();
		$sql=$q->
		from(array(
			'structure_depth'))->
		select();
		//$stmt=$this->da->prepare($sql);
		//$this->da->execute($stmt,$query->values());
		$stmt=$this->da->query($sql);
		while($obj=$stmt->fetchObject('site_dao_node',array($this->primary))){
			$result->append($obj->clean());
		}
		$this->da->closeCursor($stmt);
		return $result;
	}
}
?>